The methods were deprecated since 1.34.
Change-Id: Ib95ac1ba36a8ffd6b71ed67642d8abb2e3538bae
* @return FeedItem
*/
function feedItem( $row ) {
- $rev = new Revision( $row, 0, $this->getTitle() );
-
+ $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
+ $rev = $revisionStore->newRevisionFromRow( $row, 0, $this->getTitle() );
+ $prevRev = $revisionStore->getPreviousRevision( $rev );
+ $revComment = $rev->getComment() === null ? null : $rev->getComment()->text;
$text = FeedUtils::formatDiffRow(
$this->getTitle(),
- $this->getTitle()->getPreviousRevisionID( $rev->getId() ),
+ $prevRev ? $prevRev->getId() : false,
$rev->getId(),
$rev->getTimestamp(),
- $rev->getComment()
+ $revComment
);
- if ( $rev->getComment() == '' ) {
+ $revUserText = $rev->getUser() ? $rev->getUser()->getName() : '';
+ if ( $revComment == '' ) {
$contLang = MediaWikiServices::getInstance()->getContentLanguage();
$title = $this->msg( 'history-feed-item-nocomment',
- $rev->getUserText(),
+ $revUserText,
$contLang->timeanddate( $rev->getTimestamp() ),
$contLang->date( $rev->getTimestamp() ),
$contLang->time( $rev->getTimestamp() )
)->inContentLanguage()->text();
} else {
- $title = $rev->getUserText() .
+ $title = $revUserText .
$this->msg( 'colon-separator' )->inContentLanguage()->text() .
- FeedItem::stripComment( $rev->getComment() );
+ FeedItem::stripComment( $revComment );
}
return new FeedItem(
$text,
$this->getTitle()->getFullURL( 'diff=' . $rev->getId() . '&oldid=prev' ),
$rev->getTimestamp(),
- $rev->getUserText(),
+ $revUserText,
$this->getTitle()->getTalkPage()->getFullURL()
);
}
*/
public function getOldId() {
$oldid = $this->getRequest()->getInt( 'oldid' );
+ $rl = MediaWikiServices::getInstance()->getRevisionLookup();
switch ( $this->getRequest()->getText( 'direction' ) ) {
case 'next':
# output next revision, or nothing if there isn't one
- $nextid = 0;
+ $nextRev = null;
if ( $oldid ) {
- $nextid = $this->getTitle()->getNextRevisionID( $oldid );
+ $oldRev = $rl->getRevisionById( $oldid );
+ if ( $oldRev ) {
+ $nextRev = $rl->getNextRevision( $oldRev );
+ }
}
- $oldid = $nextid ?: -1;
+ $oldid = $nextRev ? $nextRev->getId() : -1;
break;
case 'prev':
# output previous revision, or nothing if there isn't one
+ $prevRev = null;
if ( !$oldid ) {
# get the current revision so we can get the penultimate one
$oldid = $this->page->getLatest();
}
- $previd = $this->getTitle()->getPreviousRevisionID( $oldid );
- $oldid = $previd ?: -1;
+ $oldRev = $rl->getRevisionById( $oldid );
+ if ( $oldRev ) {
+ $prevRev = $rl->getPreviousRevision( $oldRev );
+ }
+ $oldid = $prevRev ? $prevRev->getId() : -1;
break;
case 'cur':
$oldid = 0;
* @file
*/
+use MediaWiki\MediaWikiServices;
use MediaWiki\Storage\RevisionRecord;
/**
$params['text'] = $newContent->serialize( $contentFormat );
// If no summary was given and we only undid one rev,
// use an autosummary
- if ( is_null( $params['summary'] ) &&
- $titleObj->getNextRevisionID( $undoafterRev->getId() ) == $params['undo']
- ) {
- $params['summary'] = wfMessage( 'undo-summary' )
- ->params( $params['undo'], $undoRev->getUserText() )->inContentLanguage()->text();
+
+ if ( is_null( $params['summary'] ) ) {
+ $nextRev = MediaWikiServices::getInstance()->getRevisionLookup()
+ ->getNextRevision( $undoafterRev->getRevisionRecord() );
+ if ( $nextRev && $nextRev->getId() == $params['undo'] ) {
+ $params['summary'] = wfMessage( 'undo-summary' )
+ ->params( $params['undo'], $undoRev->getUserText() )
+ ->inContentLanguage()->text();
+ }
}
}
$titles = $pageSet->getGoodTitles();
$title = reset( $titles );
if ( $title ) {
- $revid = $title->getNextRevisionID( $params['newerthanrevid'], Title::READ_LATEST );
- if ( $revid ) {
- $timestamp = $dbw->timestamp(
- MediaWikiServices::getInstance()->getRevisionStore()->getTimestampFromId( $title, $revid )
- );
- } else {
- $timestamp = null;
+ $timestamp = null;
+ $rl = MediaWikiServices::getInstance()->getRevisionLookup();
+ $currRev = $rl->getRevisionById( $params['newerthanrevid'], Title::READ_LATEST );
+ if ( $currRev ) {
+ $nextRev = $rl->getNextRevision( $currRev, Title::READ_LATEST );
+ if ( $nextRev ) {
+ $timestamp = $dbw->timestamp( $nextRev->getTimestamp() );
+ }
}
}
}
<?php
+use MediaWiki\MediaWikiServices;
use MediaWiki\Storage\RevisionRecord;
/**
* @return null|string
*/
private function getPreviousRevisionTimestamp() {
- $previousRev = Revision::newFromId(
- $this->pageTitle->getPreviousRevisionID( $this->pageTitle->getLatestRevID() )
- );
-
- return $previousRev ? $previousRev->getTimestamp() : null;
+ $rl = MediaWikiServices::getInstance()->getRevisionLookup();
+ $latestRev = $rl->getRevisionByTitle( $this->pageTitle );
+ if ( $latestRev ) {
+ $previousRev = $rl->getPreviousRevision( $latestRev );
+ if ( $previousRev ) {
+ return $previousRev->getTimestamp();
+ }
+ }
+ return null;
}
}
* false signifies that there is no previous/next revision ($old is the oldest/newest one).
*/
public function mapDiffPrevNext( $old, $new ) {
+ $rl = MediaWikiServices::getInstance()->getRevisionLookup();
if ( $new === 'prev' ) {
// Show diff between revision $old and the previous one. Get previous one from DB.
$newid = intval( $old );
- $oldid = $this->getTitle()->getPreviousRevisionID( $newid );
+ $oldid = false;
+ $newRev = $rl->getRevisionById( $newid );
+ if ( $newRev ) {
+ $oldRev = $rl->getPreviousRevision( $newRev );
+ if ( $oldRev ) {
+ $oldid = $oldRev->getId();
+ }
+ }
} elseif ( $new === 'next' ) {
// Show diff between revision $old and the next one. Get next one from DB.
$oldid = intval( $old );
- $newid = $this->getTitle()->getNextRevisionID( $oldid );
+ $newid = false;
+ $oldRev = $rl->getRevisionById( $oldid );
+ if ( $oldRev ) {
+ $newRev = $rl->getNextRevision( $oldRev );
+ if ( $newRev ) {
+ $newid = $newRev->getId();
+ }
+ }
} else {
$oldid = intval( $old );
$newid = intval( $new );
}
}
+ $rl = MediaWikiServices::getInstance()->getRevisionLookup();
+ $oldRev = $this->mRevision ? $this->mRevision->getRevisionRecord() : null;
if ( $request->getVal( 'direction' ) == 'next' ) {
- $nextid = $this->getTitle()->getNextRevisionID( $oldid );
+ $nextid = 0;
+ if ( $oldRev ) {
+ $nextRev = $rl->getNextRevision( $oldRev );
+ if ( $nextRev ) {
+ $nextid = $nextRev->getId();
+ }
+ }
if ( $nextid ) {
$oldid = $nextid;
$this->mRevision = null;
$this->mRedirectUrl = $this->getTitle()->getFullURL( 'redirect=no' );
}
} elseif ( $request->getVal( 'direction' ) == 'prev' ) {
- $previd = $this->getTitle()->getPreviousRevisionID( $oldid );
+ $previd = 0;
+ if ( $oldRev ) {
+ $prevRev = $rl->getPreviousRevision( $oldRev );
+ if ( $prevRev ) {
+ $previd = $prevRev->getId();
+ }
+ }
if ( $previd ) {
$oldid = $previd;
$this->mRevision = null;
'oldid' => $oldid
] + $extraParams
);
- $prev = $this->getTitle()->getPreviousRevisionID( $oldid );
- $prevlink = $prev
+ $rl = MediaWikiServices::getInstance()->getRevisionLookup();
+ $prevExist = (bool)$rl->getPreviousRevision( $revision->getRevisionRecord() );
+ $prevlink = $prevExist
? Linker::linkKnown(
$this->getTitle(),
$context->msg( 'previousrevision' )->escaped(),
] + $extraParams
)
: $context->msg( 'previousrevision' )->escaped();
- $prevdiff = $prev
+ $prevdiff = $prevExist
? Linker::linkKnown(
$this->getTitle(),
$context->msg( 'diff' )->escaped(),
$this->setNewtalk( false );
// If there is a new, unseen, revision, use its timestamp
- $nextid = $oldid
- ? $title->getNextRevisionID( $oldid, Title::READ_LATEST )
- : null;
- if ( $nextid ) {
- $this->setNewtalk( true, Revision::newFromId( $nextid ) );
+ if ( $oldid ) {
+ $rl = MediaWikiServices::getInstance()->getRevisionLookup();
+ $oldRev = $rl->getRevisionById( $oldid, Title::READ_LATEST );
+ if ( $oldRev ) {
+ $newRev = $rl->getNextRevision( $oldRev );
+ if ( $newRev ) {
+ // TODO: actually no need to wrap in a revision,
+ // setNewtalk really only needs a RevRecord
+ $this->setNewtalk( true, new Revision( $newRev ) );
+ }
+ }
}
} );
}